﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Gsp315_AIBehaviors
{
    public static class Helper
    {
        //-------------------------------------------------------------------------
        //M001: Convert Angle: Degrees->Radians
        public static float Degree2Radian(float angleDeg)
        {
            float rad = (float)Math.Round(angleDeg * (Math.PI / 180), 2);
            return rad;
            //return (float)Math.Round(angleDeg * (Math.PI / 180), 2 );
        }

        //-------------------------------------------------------------------------
        //M002: Convert Angle: Radians->Degrees
        public static float Radian2Degree(float angleRad)
        {
            return (float)Math.Round(angleRad * (180 / Math.PI), 2);
        }

        //-------------------------------------------------------------------------
        //M003: Convert Radians->Vector2
        public static Vector2 Radian2Vector(float angleRad)
        {
            Vector2 temp = new Vector2();
            temp.X = (float)Math.Round(Math.Cos(angleRad), 2);
            temp.Y = (float)Math.Round(Math.Sin(angleRad), 2);

            return temp;
        }

        //-------------------------------------------------------------------------
        //M004: Generate a random theta, in RADIANS obj should move in
        //Use this method if single obj need angle, in ONE frame
        public static float AngleInRadians_Random()
        {
            Random rand = new Random(); //random seed, provided...
            int minTheta = 0; int maxTheta = 359;

            //Random angle between Zero|360 in DEGREES
            float angle = (float)Math.Round( ( (rand.NextDouble() * (maxTheta - minTheta) ) + minTheta ), 2);

            return Degree2Radian(angle);
        }

        //-------------------------------------------------------------------------
        //M005: Generate a random theta, in RADIANS obj should move in
        //Use this method if multiple objs need random angle, in ONE frame
        public static float AngleInRadians_Random(Random rand)
        {
            int minTheta = 0; int maxTheta = 359;

            //Random angle between Zero|360 in DEGREES
            float angle = (float)Math.Round(((rand.NextDouble() * (maxTheta - minTheta)) + minTheta), 2);

            return Degree2Radian(angle);
        }

        //-------------------------------------------------------------------------
        //M006: Generate a random vector2 based on given min|max range
        //Use this method for single obj position, in ONE frame
        public static Vector2 Position_Random(int minX, int maxX, int minY, int maxY)
        {
            Random rand = new Random(); //new Random((int)DateTime.Now.Ticks); //random seed...

            //X-Value: Generate a random 'float 2-decimal places' between a min|max range
            float x = (float)Math.Round( ( (rand.NextDouble() * (maxX - minX) ) + minX ), 2);
            //Y-Value: Generate a random 'float 2-decimal places' between a min|max range
            float y = (float)Math.Round( ( (rand.NextDouble() * (maxY - minY) ) + minY ), 2);

            return new Vector2(x, y);
         }

        //-------------------------------------------------------------------------
        //M007: Generate a random vector2 based on given min|max range
        //Use this method if multiple objs need random position, in ONE frame
        public static Vector2 Position_Random(Random xPosSeed, Random yPosSeed, int minX, int maxX, int minY, int maxY)
        {
            //X-Value: Generate a random 'float 2-decimal places' between a min|max range
            float x = (float)Math.Round(((xPosSeed.NextDouble() * (maxX - minX)) + minX), 2);
            //Y-Value: Generate a random 'float 2-decimal places' between a min|max range
            float y = (float)Math.Round(((yPosSeed.NextDouble() * (maxY - minY)) + minY), 2);

            return new Vector2(x, y);
        }

    }//class
}//namespace
